#ifndef KERNEL_HAL_HARDWARE_H
#define KERNEL_HAL_HARDWARE_H

#if TRACE_HAL
#define HAL_TRACE(x ...) TRACE("Hal: " x)
#else
#define HAL_TRACE(x ...)
#endif

#if TRACE_HAL_DETAILED
#define HAL_TRACE_DETAILED(x ...) HAL_TRACE(x)
#else
#define HAL_TRACE_DETAILED(x ...)
#endif

#include <Mint/Types.h>
#include "Hal/ITaskContext.h"
#include "Interfaces/ITextOutput.h"

extern "C"
{
	typedef void (* InterruptHandler_t)( ITaskContext * );
	typedef void (* TaskEntry_t)( void * );
};

class IHardware
{
friend class CKernel;
public:
	virtual Result Initialize( void ) = 0;
	virtual void Lock( void ) = 0;
	virtual void Unlock( void ) = 0;
	virtual void AddInterruptHandler( int interrupt, InterruptHandler_t handler ) = 0;
	virtual ITaskContext * CreateContext( void * stackPointer, Size stackSize, TaskEntry_t entry, void * argument ) = 0;
	virtual ITaskContext * CreateEmptyContext( void ) = 0;
	virtual void DisposeContext( ITaskContext * context ) = 0;
	virtual void YieldContext( ITaskContext * context ) = 0;
	virtual void SwitchContext( ITaskContext * oldContext, ITaskContext * currentContext, ITaskContext * newContext ) = 0;
	virtual void DumpContext( ITaskContext * context, ITextOutput * output ) = 0;
	virtual void DumpCurrentContext( ITextOutput * output ) = 0;

protected:
	virtual void ForceLock( void ) = 0;
	virtual void ForceUnlock( void ) = 0;
};

extern IHardware * Hardware;

#endif // KERNEL_HAL_HARDWARE_H
